home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Graphics / TVPaint / Rexx / LineNumber.rx < prev    next >
Encoding:
Text File  |  1995-11-07  |  823 b   |  97 lines

  1. /*
  2.     param line
  3.  
  4.     Draw a line with n dots
  5.     Modify n: the number of dots on the line
  6.  
  7. */
  8.  
  9.  
  10. address 'rexx_TVPaint'
  11.     
  12.     parse ARG m x1 y1 x2 y2 b
  13.     if(m~='Line')then
  14.     do
  15.         tv_warn 'I need LINE parameters'
  16.         exit
  17.     end
  18.  
  19.  
  20.     n=5
  21.     
  22.  
  23.     tv_UpdateUndo
  24.     x=x1
  25.     y=y1
  26.  
  27.     tv_dot x y
  28.     if (n<2) then n=2
  29.  
  30.     iy=1
  31.     dy=y2-y1
  32.     if (dy<0) then
  33.     do
  34.         dy=-dy
  35.         iy=-1
  36.     end
  37.  
  38.  
  39.     ix=1
  40.     dx=x2-x1
  41.     if (dx<0) then
  42.     do
  43.         dx=-dx
  44.         ix=-1
  45.     end
  46.  
  47.     cl=1
  48.  
  49.     if (dx>dy) then
  50.     do
  51.         l=dx%(n-1)
  52.         d=dx
  53.         do while (x~==x2)
  54.  
  55.             x=x+ix
  56.             d=d-dy
  57.  
  58.             if (d<0) then
  59.             do
  60.                 y=y+iy
  61.                 d=d+dx
  62.             end
  63.  
  64.             if(cl=l) then
  65.             do
  66.                 tv_dot x y
  67.                 cl=0
  68.             end
  69.             cl=cl+1
  70.         end
  71.     end
  72.     else
  73.     do
  74.         l=dy%(n-1)
  75.         d=dy
  76.         do while (y ~==y2)
  77.  
  78.             y=y+iy
  79.             d=d-dx
  80.  
  81.             if (d<0) then
  82.             do
  83.                 x=x+ix
  84.                 d=d+dy
  85.             end
  86.  
  87.             if(cl=l) then
  88.             do
  89.                 tv_dot x y
  90.                 cl=0
  91.             end
  92.             cl=cl+1
  93.         end
  94.     end
  95.  
  96.  
  97.